package cn.itsource.basic.controller;

import cn.itsource.basic.service.IVerificationCodeService;
import cn.itsource.basic.util.AxajResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verification")
public class VerificationCodeController {


    @Autowired
    private IVerificationCodeService verificationCodeService;

    /**
     * 注册用户信息，发送的手机验证码
     * @return
     */
    @PostMapping("/sendRegisterMobileCode")
    public AxajResult sendRegisterMobileCode(@RequestBody Map<String,String> param){
        try {
            //获取手机号码
            String phone = param.get("phone");
            //根据手机号码发送验证码
            verificationCodeService.sendRegisterMobileCode(phone);
            return new AxajResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AxajResult(false, e.getMessage());
        }
    }
}
